import java.util.Map;
import java.util.Set;

/**
 * @author lcl
 * @DateTime 2024/10/30 0:45
 */
public class Store {
    private Apple apple;
    private Mango mango;
    private Strawberry strawberry;

    public Apple getApple() {
        return apple;
    }

    public void setApple(Apple apple) {
        this.apple = apple;
    }

    public Mango getMango() {
        return mango;
    }

    public void setMango(Mango mango) {
        this.mango = mango;
    }

    public Strawberry getStrawberry() {
        return strawberry;
    }

    public void setStrawberry(Strawberry strawberry) {
        this.strawberry = strawberry;
    }

    /**
     *
     1、有一家超市，出售苹果和草莓。其中苹果 8 元/斤，草莓 13 元/斤。
     现在顾客 A 在超市购买了若干斤苹果和草莓，需要计算一共多少钱？
     请编写函数，对于 A 购买的水果斤数 (水果斤数为大于等于 0 的整数)，计算并返回所购买商品的总价。
     */
    public double pay(Map<Fruit, Integer> cart){
        Set<Map.Entry<Fruit, Integer>> entries = cart.entrySet();
        double amount = 0;
        for(Map.Entry<Fruit, Integer> entry : entries){
            Fruit fruit = entry.getKey();
            Integer count = entry.getValue();
            amount += fruit.getPrice() * fruit.getDiscount() * count;
        }
        return amount;
    }
}
